package com.itheima.homework;

import java.io.*;

/**
 * @Author 王加鑫
 * @Date 2021/5/19 20:13
 * @Version 1.0
 * 4、【编号：1802】请使用缓冲流将D盘下的某个音频或者视频文件，拷贝到当前模块目录下，并计算拷贝过程消耗的时间，将时间（单位毫秒）打印到控制台。
 */
public class Demo04 {
    public static void main(String[] args) throws IOException {
        long startTime = System.currentTimeMillis();
        copy();
        long endTime = System.currentTimeMillis();
        System.out.println("花了" + (endTime - startTime));

    }

    public static void copy() throws IOException {
        BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream("D:\\Tlias\\陈辉老师的上课资料\\idea 2019.1\\ideaIU-2019.1.exe"));
        BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream("day12_file&字节流/ideaIU-2019.1.exe"));
        byte[] bytes = new byte[1024*10];
        int len;
        while ((len = inputStream.read(bytes)) != -1){
            outputStream.write(bytes,0,len);
        }
        inputStream.close();
        outputStream.close();

    }
}
